<template name='newtime'>
	<view>
		<view class="usertime" style="color: #ccc; font-size: 22rpx;">
			<text>剩余{{djs}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		
		name: 'newtime', //组件名称
		props:{
			item: {
				type: Object,
				default: null
			}
		},
		data() {
			return {
				djs:'',
			}
		},
		methods: {
			ptdaojishi() {
				
				//倒计时
				let _end = new Date(Date.parse(this.item.time.replace(/-/g, '/'))); //活动结束时间
				var _now = new Date(); //当前时间
				var _leftTime = _end.getTime() - _now.getTime();
				if (_leftTime > 0) {
					// let _day = Math.floor(_leftTime / (1000 * 60 * 60 * 24));
					let _hour = Math.floor((_leftTime / (1000 * 60 * 60)) % 24);
					let _min = Math.floor((_leftTime / (1000 * 60)) % 60);
					let _sec = Math.floor((_leftTime / 1000) % 60);
					// _day = _day > 9 ? _day : '0' + _day;
					
					_hour = _hour > 9 ? _hour : '0' + _hour;
					
					_min = _min > 9 ? _min : '0' + _min;
					
					_sec = _sec > 9 ? _sec : '0' + _sec;
					this.djs = _hour +':' + _min+':'+ _sec
					
					
				} else {
					this.djs = "00:00:00"
				}
			},
		},
		created() {
			setInterval(() => {
				this.ptdaojishi();
			}, 1000);
		}
	}
</script>

<style>

</style>
